package ch.kerbtier.malurus.components;

import ch.kerbtier.malurus.ActionListener;
import ch.kerbtier.malurus.coreimpl.CiComponent;
import ch.kerbtier.malurus.coreimpl.CiEvent;
import ch.kerbtier.malurus.coreimpl.Listeners;

public class Button extends CiComponent {
	private Listeners onClick = new Listeners();
	private String label;

	public void addOnClickListener(ActionListener a) {
		onClick.add(a);
	}

	public void removeOnClickListener(ActionListener a) {
		onClick.remove(a);
	}

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		if (label != null && !label.equals(this.label)) {
			this.label = label;
			setModified(true);
		}
	}
	
	public void action(){
		onClick.execute(new CiEvent(this, getInstance()));
	}
}
